﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using NSsh.Common.Types;
using NUnit.Framework.SyntaxHelpers;
using System.IO;
using System.Collections;

namespace NSsh.Common.Tests.Types
{
    [TestFixture]
    public class EncryptionAlgorithmHelperFixture
    {
        [Test]
        public void ShouldParseCorrectly()
        {
            Assert.That(EncryptionAlgorithmHelper.Parse(EncryptionAlgorithmHelper.None), Is.EqualTo(EncryptionAlgorithm.None));
            Assert.That(EncryptionAlgorithmHelper.Parse(EncryptionAlgorithmHelper.TripleDesCbc), Is.EqualTo(EncryptionAlgorithm.TripleDesCbc));
            Assert.That(EncryptionAlgorithmHelper.Parse(EncryptionAlgorithmHelper.BlowfishCbc), Is.EqualTo(EncryptionAlgorithm.BlowfishCbc));
            Assert.That(EncryptionAlgorithmHelper.Parse(EncryptionAlgorithmHelper.Aes128Cbc), Is.EqualTo(EncryptionAlgorithm.Aes128Cbc));
        }

        [Test]
        public void ShouldToStringCorrectly()
        {
            Assert.That(EncryptionAlgorithmHelper.ToString(EncryptionAlgorithm.None), Is.EqualTo(EncryptionAlgorithmHelper.None));
            Assert.That(EncryptionAlgorithmHelper.ToString(EncryptionAlgorithm.TripleDesCbc), Is.EqualTo(EncryptionAlgorithmHelper.TripleDesCbc));
            Assert.That(EncryptionAlgorithmHelper.ToString(EncryptionAlgorithm.BlowfishCbc), Is.EqualTo(EncryptionAlgorithmHelper.BlowfishCbc));
            Assert.That(EncryptionAlgorithmHelper.ToString(EncryptionAlgorithm.Aes128Cbc), Is.EqualTo(EncryptionAlgorithmHelper.Aes128Cbc));
        }

        [Test]
        public void ShouldFailForInvalidAlgorithm()
        {
            Assert.That(new MethodInvoker(delegate
            {
                EncryptionAlgorithmHelper.ToString((EncryptionAlgorithm)(-1));

            }), Throws.Exception<ArgumentException>());

            Assert.That(new MethodInvoker(delegate
            {
                EncryptionAlgorithmHelper.Parse("bogus");

            }), Throws.Exception<ArgumentException>());
        }
    }
}
